import java.util.Arrays;

public class Test44 {
    public static boolean isContinuous(int[] numbers){
        if (numbers == null || numbers.length < 0) return false;

        Arrays.sort(numbers); //排序
        int numberZeros = 0;
        int numberOfGap  = 0;
        for (int i = 0; i<numbers.length && numbers[i] == 0;i++) numberZeros  ++ ;
        if (numberZeros > 2) return false;
        //第一个非0元素的位置
        int samll = numberZeros;
        int big = samll+1;

        while (big < numbers.length){
            if (numbers[samll] == numbers[big]) return false;
            numberOfGap += numbers[big] - numbers[samll] -1;
            samll = big;
            big ++;
        }
        return numberOfGap  <= numberZeros;

    }

    public static void main(String[] args) {
        int[] numbers1 = {1, 3, 2, 5, 4};
        System.out.println(isContinuous(numbers1));
        int[] numbers2 = {1, 3, 2, 6, 4};
        System.out.println(isContinuous(numbers2));
        int[] numbers3 = {0, 3, 2, 6, 4};
        System.out.println(isContinuous(numbers3));

    }
}
